import { FromOptionsProp } from "../interface";

export const useDate = model => {
  // 设置时间弹框样式
  const setDateClass = (item: FromOptionsProp) => {
    const type = item?.attrs?.type;
    if (type === "daterange") {
      // 日期选择
      return " daterange-data-box";
    } else if (type === "datetimerange") {
      // 日期时间选择
      return " datetimerange-date-box";
    }
    return " data-box";
  };

  // 根据有无内容设置值的样式
  const dateValueClass = item => (model.value[item.prop]?.length ? "have-value" : "");

  return {
    setDateClass,
    dateValueClass
  };
};
